﻿Imports System.IO
Public Class Notenauflistung
    Dim Daten As XML_bearbeiten = New XML_bearbeiten
    Private Sub loading()
        LabelFach.Text = Notenberechner1.Fach_name

        ListBox1.Items.Clear()
        Dim i As Integer
        For i = 0 To Daten.daten.FächerAnz - 1
            If Daten.daten.Fächer(i).name = Notenberechner1.Fach_name Then
                Dim i1 As Integer
                For i1 = 0 To Daten.daten.Fächer(i).notenAnz - 1
                    ListBox1.Items.Add(Daten.daten.Fächer(i).notenArray(i1).typ + " | " _
                                       + Daten.daten.Fächer(i).notenArray(i1).punkte.ToString + " | " _
                                       + Daten.daten.Fächer(i).notenArray(i1).datum + " | " _
                                       + Daten.daten.Fächer(i).notenArray(i1).bemerkung)
                Next
            End If
        Next
    End Sub

    Private Sub Notenauflistung_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Daten.XMLReader()
        loading()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim i As Integer
        For i = 0 To Daten.daten.FächerAnz - 1
            If Daten.daten.Fächer(i).name = Notenberechner1.Fach_name Then
                Dim i1 As Integer
                For i1 = 0 To Daten.daten.Fächer(i).notenAnz - 1
                    If i1 = ListBox1.SelectedIndex Then
                        Daten.daten.Fächer(i).notenArray(i1) = Nothing
                        Daten.daten.Fächer(i).notenAnz = Daten.daten.Fächer(i).notenAnz - 1
                    End If
                Next
            End If
        Next
        Daten.XMLWriter(Daten)
        Daten = New XML_bearbeiten
        Daten.XMLReader()
        loading()
        Notenberechner1.loading()
    End Sub
End Class